package com.wing.product.model.response;

import com.baomidou.mybatisplus.annotation.TableField;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.wing.cabinet.utils.ExcelExport;
import com.wing.product.model.entity.Product;
import com.wing.product.model.entity.ProductDetail;
import com.wing.product.model.entity.ProductType;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;
import org.springframework.format.annotation.DateTimeFormat;

import java.math.BigDecimal;
import java.time.LocalDateTime;

/**
 * 产品明细表VO
 *
 * @author
 */
@Data
@NoArgsConstructor
@Accessors(chain = true)
public class ProductDetailVO {

    /**
     * ID
     */
    private Long id;

    /**
     * 创建时间
     */
    @JsonFormat(timezone = "GMT+8" , pattern = "yyyy-MM-dd HH:mm:ss" )
    private LocalDateTime createTime;

    /**
     * 更新添加时间
     */
    @JsonFormat(timezone = "GMT+8" , pattern = "yyyy-MM-dd HH:mm:ss" )
    private LocalDateTime updateTime;
    /**
     * 创建者
     */
    private Long creator;

    /**
     * 修改者
     */
    private Long modifier;

    /**
     * 创建人
     */
    private String creatorName;

    /**
     * 修改人
     */
    private String modifierName;

    /**
     * 商品ID
     */
    private Long productId;

    /**
     * 商品SKU编码
     */
    @ExcelExport(value = "物料编号",sort = 20)
    private String skuCode;

    /**
     * 商品缩略图
     */
    private String productPic;

    /**
     * 商品SKU名称
     */
    @ExcelExport(value = "物料名称",sort = 10)
    private String skuName;

    /**
     * 商品规格列表
     */
    private String skuSpec;

    /**
     * 商品规格值列表
     */
    private String skuSpecValue;

    /**
     * 商品规格值名称列表
     */
    private String skuSpecValueNames;

    /**
     * 企业货号
     */
    private String enterpriceCode;

    /**
     * 市场指导价
     */
    @ExcelExport(value = "市场价",sort = 50)
    private BigDecimal marketPrice;

    /**
     * 商品店铺价
     */
    private BigDecimal storePrice;

    /**
     * 最低活动价
     */
    private BigDecimal activityPrice;

    /**
     * 平台供货价
     */
    private BigDecimal supplyPrice;

    /**
     * 库存数
     */
    private Integer stockNumber;

    /**
     * 商品条码
     */
    private String barcode;

    /**
     * 排序
     */
    private Integer sortNumber;

    /**
     * 入驻企业ID
     */
    private Long settledCompanyId;

    /**
     * 状态
     */
    private ProductDetail.Status status;
    /**
     * 是否已同步：no(0,未同步);yes(1,已同步);
     */
    private ProductDetail.IsSyns isSyns;

    /**
     * 状态描述
     */
    @TableField(exist = false)
    private String statusDesc;

    public String getStatusDesc() {
        return status == null ? null : status.getDesc();
    }

    /**
     * 产品名称
     */
    @ExcelExport(value = "所属系列",sort = 60)
    private String productName;

    /**
     * 产品分类
     */
    private String productCategoryName;
    /**
     * 产品品牌
     */
    @ExcelExport(value = "品牌",sort = 40)
    private String productBrandName;

    private Long skuId;

    private BigDecimal price;

    private Product.Type productType;

    private BigDecimal total;

    private Long quantityConfirm;

    /**
     * 当前库存
     */
    private Long currentStock;


    private Product.DataSourceType dataSourceType;

    /**
     * 产品类型ID
     */
    private Long productTypeId;

    /**
     * 产品类型名称
     */
    @TableField(exist = false)
    @ExcelExport(value = "所属类型",sort = 70)
    private String productTypeName;

    /**
     * 产品分类ID
     */
    private Long productCategoryId;

    /**
     * 产品分类名称
     */
    @TableField(exist = false)
    private String categoryName;

    /**
     * 单位ID
     */
    private Long unitId;

    /**
     * 单位名称
     */
    @TableField(exist = false)
    @ExcelExport(value = "包装单位",sort = 130)
    private String unitName;

    /**
     * 品牌ID
     */
    private Long brandId;

    /**
     * 品牌名称
     */
    @TableField(exist = false)
    private String brandName;

    /**
     * 计价方式:piece(0,按件);weight(1,按重量)'
     */
    private ProductDetail.PricingMethod pricingMethod;

    /**
     * 计价方式描述
     */
    @TableField(exist = false)
    private String pricingMethodDesc;

    public String getPricingMethodDesc() {
        return pricingMethod == null ? null : pricingMethod.getDesc();
    }

    /**
     * 同步时间
     */
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
    private LocalDateTime synsTime;

    /**
     * 用于区分云端云仓手动添加产品
     */
    private String skuCodeAs;

    /**
     * 产品编码
     */
    private String productCode;

    /**
     * 老SKU编码码
     */
    private String oldSkuCode;

    /**
     * 老规格码
     */
    @ExcelExport(value = "规格码",sort = 30)
    private String oldSpecCode;

    /**
     * 包装id
     */
    private Long packId;

    /**
     * 渠道价
     */
    private BigDecimal spPrice;

    /**
     * 厂家名
     */
    private String companyName;
    /**
     * 仓库ID
     */
    private Long warehouseId;

    private String skuPic;

    /**
     * 寿命单位
     */
    private  ProductDetail.LifeUnit  lifeUnit;
    /**
     * 使用寿命
     */
    private Integer lifeSpan;

    /**
     * 库存数量
     */
    @ExcelExport(value = "库存(包装计)",sort = 90)
    private Long quantity;

    /**
     * 安全库存数量
     */
    @ExcelExport(value = "告警设置库存",sort = 200)
    private String warningQuantity;

    /**
     * 是否来源简版  0  不是   1 是
     */
    private Integer simplify;

    private BigDecimal baseWeight;

    private BigDecimal weightNumber;

    private ProductType.WeightUnit weightUnit;

    private String weightUnitName;

    private String weightUnitDesc;

    public String getWeightUnitName(){
        if (this.weightUnit!=null){
            return this.weightUnit.getDesc();
        }
        return "";
    }


    public String getWeightUnitDesc(){
        if (this.weightUnit!=null){
            return this.weightUnit.getDesc();
        }
        return "";
    }


    /**
     * 归还时长阈值
     */
    private Integer returnThreshold;

    /**
     * 呆滞时长阈值
     */
    private Integer lethargyThreshold;

    private String lifeUnitDesc;

    public String getLifeUnitDesc(){
        if (this.lifeUnit!=null){
            return this.lifeUnit.getDesc();
        }
        return "";
    }

    private ProductDetail.InventoryUnitType inventoryUnitType;

    private Boolean returnType;

    private String inventoryUnitTypeDesc;

    public String getInventoryUnitTypeDesc(){
        if (inventoryUnitType!=null){
            return this.inventoryUnitType.getDesc();
        }
        return "";
    }

    private ProductDetail.StorageKnifeType storageKnifeType;

    public String getStorageKnifeTypeDesc(){
        if (storageKnifeType!=null){
            return this.storageKnifeType.getDesc();
        }
        return "";
    }


    private Integer currentCabStock;

    private BigDecimal skuWeightUnit;

    private Integer quantityCellCab;

    private Integer quantityTempCab;

    private Integer quantityCab;

    public Integer getQuantityCab(){
        Integer sum=0;
        if(this.quantityCellCab!=null){
            sum+=this.quantityCellCab;
        }
        if (this.quantityTempCab!=null){
            sum+=this.quantityTempCab;
        }
        return sum;
    }

    private Integer currentTempCabStock;

    public Integer getCurrentCabStock(){
        Integer sum=0;
        if (this.currentCabStock!=null){
            sum+=this.currentCabStock;
        }
        if (this.currentTempCabStock!=null){
            sum+=this.currentTempCabStock;
        }
        return sum;
    }

    /**
     * 供应商id
     */
    private Long supplierId;

    /**
     * 供应商名称
     */
    private String corporateName;

    /**
     * 最小单位数量,e.g:一包十只，两包，此值为：20
     */
    @ExcelExport(value = "库存(基础单位计)",sort = 140)
    private Integer quantityPack;

    /**
     * 包装数量，e.g,一包十只，此值为：10
     */
    private Integer quantityPackUnit;

    /**
     * 包装名
     */
    @ExcelExport(value = "包装规格",sort = 80)
    private String packName;

    private String remark;
    @TableField(exist = false)
    private String basicsUnitName;

    /**
     * 换算率
     */
    private Integer baseRate;
    /**
     * 暂存柜库存
     */
    private Integer storageQuantity;
    /**
     * 领新柜库存
     */
    private Integer inventoryQuantity;

    /**
     * 基础单位单价
     */
    private BigDecimal basePrice;

    /**
     * 基础单位数量
     */
    private Integer baseQuantity;

    /**
     * 售刀柜-库存(包装计)
     */
    @ExcelExport(value = "售刀柜-库存(包装计)",sort = 100)
    private Integer ccipQuantity;

    /**
     * 售刀柜-库存(基础单位计)
     */
    @ExcelExport(value = "售刀柜-库存(基础单位计)",sort = 150)
    private Integer ccipQuantityPack;

    /**
     * 存刀柜-库存(包装计)
     */
    @ExcelExport(value = "存刀柜-库存(包装计)",sort = 120)
    private Integer csipQuantity;

    /**
     * 存刀柜-库存(基础单位计)
     */
    @ExcelExport(value = "存刀柜-库存(基础单位计)",sort = 160)
    private Integer csipQuantityPack;
}
